/*D:\1703b\task\day8\tcb*/
var gulp = require("gulp"),
	webserver = require("gulp-webserver"),
	livereload = require("gulp-livereload"),
	uglify = require("gulp-uglify"),
	rename = require("gulp-rename"),
	sourcemaps = require("gulp-sourcemaps"),
	sass = require('gulp-ruby-sass');

//自动刷新
gulp.task("webserver",function(){
	gulp.src("src")
		.pipe(webserver({
			livereload:true,
			open:true,
			port:6666
		}))
})
//把开发环境发布到发布环境
gulp.task("html",function(){
	return gulp.src("src/**/*.html")
				.pipe(gulp.dest("dest/"))
})

//sass编译文件
gulp.task("sass",function(){
	return sass("src/sass/*.scss",{style:"compressed"})
		.on("error",function(err){
			console.log(err)
		})
		.pipe(gulp.dest("desk/css"))
})

//js编译文件
/*gulp.task("js",function(){
	return gulp.src("src/js/*.js")
				.pipe(sourcemaps.init())
				.pipe(uglify())
				.pipe(rename({suffix:".min"}))
				.pipe(sourcemaps.write("map"))
				.pipe(gulp.dest("dest/js"))
})*/

//监听任务
gulp.task("watch",function(){
	gulp.watch("src/**/*.html",["html"]);
	gulp.watch("src/sass/*.scss",["sass"]);
	// gulp.watch("src/js/*.js",["js"]);
})
//自动默认执行
gulp.task("default",['webserver','html'/*,'js'*/,'sass','watch']);